//koa基础包（服务器）
const Koa = require('koa')
//接收参数
const koaBody = require('koa-body')
//路由
const route = require('koa-route')
//跨域
const cors = require('koa2-cors')
//路径
const path = require('path');
//设置静态文件夹
const Koastatic = require('koa-static')
const koastatics = Koastatic(path.join(__dirname))


//创建koa对象
const app = new Koa();

//跨域
app.use(cors({
	origin: "*",
	exposeHeaders: ["WWW-Authenticate", "Server-Authorization", "Date"],
	maxAge: 100,
	credentials: true,
	allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
	allowHeaders: ["Content-Type", "Authorization", "Accept", "X-Custom-Header", "anonymous"]
}));

app.use(koaBody());
app.use(koastatics);


//路由设置

//注册
app.use(route.post('/reg', require('./route/reg.js')))

//登录
app.use(route.post('/login', require('./route/login.js')))

//商品分类列表
app.use(route.post('/goodslist', require('./route/goodslist')));

//商品常用列表
app.use(route.post('/goodsofftenlist', require('./route/goodsofftenlist')));

//订单添加
app.use(route.post('/orderlistadd', require('./route/orderlistAdd')));

//查询订单
app.use(route.post('/orderlistget', require('./route/orderlistGet')));

//route.get("请求地址","响应的方法")
// app.use(route.post('/raoqi',require('./route/reg.js')))



//服务器监听3333
app.listen(3333);
